package web.servlet.zy5.login.dao;


import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import web.servlet.datasource.book.JDBCUtils;
import web.servlet.zy5.login.domin.User;

public class UserDaoImpl implements UserDao {
    JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
    String sql = "";

    @Override
    public User login(String username, String password) {
        sql = "select * from user where username=? and password=?";
        try {
            return template.queryForObject(sql, new BeanPropertyRowMapper<User>(User.class),
                    username, password);
        } catch (Exception e) {
            System.out.println(e.getMessage());
            return null;
        }

    }
}